package test_model_base;

import static org.junit.Assert.*;
import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.servlet.model.base.Administrator;

public class AdministratorTest extends TestCase {
	private Administrator admin;

	@Before
	public void setUp() throws Exception {
		super.setUp();
		admin = new Administrator("admin", 0.5, 0.5, 0.5);
	}

	@After
	public void tearDown() throws Exception {
		admin = null;
	}

	@Test
	public void testAdministrator() {
		admin = new Administrator();
		Assert.assertNull(admin.getPasswd());
		Assert.assertEquals(0.0, admin.getCoefPro());
		Assert.assertEquals(0.0, admin.getCoefProfile());
		Assert.assertEquals(0.0, admin.getCoefStudy());
	}

	@Test
	public void testAdministratorStringDoubleDoubleDouble() {
		admin = new Administrator("root", 1.0, 1.0, 1.0);
		Assert.assertEquals("root", admin.getPasswd());
		Assert.assertEquals(1.0, admin.getCoefPro());
		Assert.assertEquals(1.0, admin.getCoefProfile());
		Assert.assertEquals(1.0, admin.getCoefStudy());
	}

	@Test
	public void testGetIs_modified_passwd() {
		Assert.assertEquals(false, admin.getIs_modified_passwd());
	}

	@Test
	public void testGetIs_modified_coefProfile() {
		Assert.assertEquals(false, admin.getIs_modified_coefProfile());
	}

	@Test
	public void testGetIs_modified_coefStudy() {
		Assert.assertEquals(false, admin.getIs_modified_coefStudy());
	}

	@Test
	public void testGetIs_modified_coefPro() {
		Assert.assertEquals(false, admin.getIs_modified_coefPro());
	}

	@Test
	public void testSetIs_modified_passwd() {
		Assert.assertEquals(false, admin.getIs_modified_passwd());
		admin.setIs_modified_passwd(true);
		Assert.assertEquals(true, admin.getIs_modified_passwd());
	}

	@Test
	public void testSetIs_modified_coefProfile() {
		Assert.assertEquals(false, admin.getIs_modified_coefProfile());
		admin.setIs_modified_coefProfile(true);
		Assert.assertEquals(true, admin.getIs_modified_coefProfile());
	}

	@Test
	public void testSetIs_modified_coefStudy() {
		Assert.assertEquals(false, admin.getIs_modified_coefStudy());
		admin.setIs_modified_coefStudy(true);
		Assert.assertEquals(true, admin.getIs_modified_coefStudy());
	}

	@Test
	public void testSetIs_modified_coefPro() {
		Assert.assertEquals(false, admin.getIs_modified_coefPro());
		admin.setIs_modified_coefPro(true);
		Assert.assertEquals(true, admin.getIs_modified_coefPro());
	}

	@Test
	public void testGetPasswd() {
		Assert.assertEquals("admin", admin.getPasswd());
	}

	@Test
	public void testSetPasswd() {
		admin.setPasswd("root");
		Assert.assertEquals("root", admin.getPasswd());
	}

	@Test
	public void testGetCoefProfile() {
		Assert.assertEquals(0.5, admin.getCoefProfile());
	}

	@Test
	public void testSetCoefProfile() {
		admin.setCoefProfile(1.0);
		Assert.assertEquals(1.0, admin.getCoefProfile());
	}

	@Test
	public void testGetCoefPro() {
		Assert.assertEquals(0.5, admin.getCoefPro());
	}

	@Test
	public void testSetCoefPro() {
		admin.setCoefPro(1.0);
		Assert.assertEquals(1.0, admin.getCoefPro());
	}

	@Test
	public void testGetCoefStudy() {
		Assert.assertEquals(0.5, admin.getCoefStudy());
	}

	@Test
	public void testSetCoefStudy() {
		admin.setCoefStudy(1.0);
		Assert.assertEquals(1.0, admin.getCoefStudy());
	}

	@Test
	public void testGenerateInsertSQL() {
		Assert.assertEquals("INSERT INTO Administrator VALUES ('admin' ,0.5 , 0.5 , 0.5)", 
				admin.generateInsertSQL());
	}

	@Test
	public void testGenerateDeleteSQL() {
		Assert.assertEquals("DELETE FROM Administrator WHERE passwd='admin'", 
				admin.generateDeleteSQL());
	}

}
